package com.example.sxt_practise.java并发编程;

import java.util.concurrent.TimeUnit;

/**
 * @author gaofeng
 * date 2022年01月03日 10:32
 */

public class TestThread {
    public static void main(String[] args) {
        Thread thread = new Thread("gao1") {
            @Override
            public void run() {
                super.run();
                try {
                    TimeUnit.SECONDS.sleep(1000);
                    //Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println(Thread.currentThread().getName() + "执行线程方法");
            }
        } ;
        thread.setName("gao1");

        /**
         * 启动线程
         */
        thread.start();
        System.out.println("main线程方法");
            thread.interrupt();
            System.out.println("被打断了");

        System.out.println("========================");

        
    }
}
